var lis = document.getElementsByTagName("h3"),
    ems = document.getElementsByTagName("em"),
    divs = document.getElementsByClassName("bottom");
for (let j = 0; j < lis.length; j++) {
    lis[j].onmouseover = function () {
        for (var i = 0; i < divs.length; i++) {
            lis[i].className = "";
            ems[i].className = "";
            divs[i].className = "bottom";
        }
        this.className = "active ";
        ems[j].className = "active";
        divs[j].className = "active bottom";
    }
}












function lb() {
    var btns = document.getElementsByClassName("c1"),
        imgs = document.getElementsByClassName("i1"),
        lis = document.getElementsByClassName("l1"),
        j = 0;//关键点：计数器
    console.log(lis);
    for (var i in btns) {
        btns[i].onclick = function () {
            if (this.innerText == ">") {
                j++;
                j == 3 && (j = 0);
                cleal()
            } else {
                j--;
                j == -1 && (j = 2);
                cleal()
            }
        }
    }
    for (var i = 0; i < lis.length; i++) {
        lis[i].onclick = function () {
            console.log(1);
            j = parseInt(this.getAttribute("dy"))
            cleal()
        }
    }

    timer = setInterval(() => {
        j++;
        j == 3 && (j = 0);
        cleal()

    }, 3000);
    var car = document.getElementsByClassName("carousel")[0];
    console.log(car);
    car.onmouseover = function () {
        clearInterval(timer);
    }
    car.onmouseout = function () {
        clearInterval(timer);
        timer = setInterval(() => {
            j++;
            j == 3 && (j = 0);
            cleal()
        }, 3000);
    }

    function cleal() {

        for (var i = 0; i < lis.length; i++) {
            imgs[i].className = "i1"
            lis[i].className = "l1"
        }
        imgs[j].className = "active i1"
        lis[j].className = "active l1"
    }

}
lb()